package qdu.edu.com.fushanf4.service.sort.twosort;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import qdu.edu.com.fushanf4.utils.ConfigurationUtil;
import qdu.edu.com.fushanf4.utils.DriverUtil;

import java.io.IOException;

/**
 * 用来二次排序
 * 主要关键字是第一列的第一个字（升序），次要关键字是第二列的整数值（降序）
 *
 * 输入路径：/hadoop/service/count/usertype/search2characters/count/split/output
 * 输出路径：/hadoop/service/sort/twosort/output
 */
public class SortByTextAndThenByIntWritableDriver extends DriverUtil {
    @Override
    public Job runJob(String[] path) throws IOException {
        Job job = ConfigurationUtil.getJob();

        job.setJarByClass(SortByTextAndThenByIntWritableDriver.class);
        job.setMapperClass(SortByTextAndThenByIntWritableMapper.class);
        job.setReducerClass(SortByTextAndThenByIntWritableReducer.class);
//        job.setCombinerClass(SortByTextAndThenByIntWritableReducer.class);

        job.setMapOutputKeyClass(TextAndIntWritableBean.class);
        job.setMapOutputValueClass(IntWritable.class);
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(IntWritable.class);

        ConfigurationUtil.setPathAndRunJob(path, job);
        return job;
    }
}
